package cn.backflow.generator.util.typemapping;


public class DatabaseTypeUtils {

    public static String getDatabaseTypeByJdbcDriver(String driver) {
        if (driver == null) {
            return null;
        }
        driver = driver.toLowerCase();
        if (driver.contains("mysql")) {
            return "mysql";
        }
        if (driver.contains("oracle")) {
            return "oracle";
        }
        if (driver.contains("com.microsoft.sqlserver.jdbc.sqlserverdriver")) {
            return "sqlserver2005";
        }
        if (driver.contains("microsoft") || driver.contains("jtds")) {
            return "sqlserver";
        }
        if (driver.contains("postgresql")) {
            return "postgresql";
        }
        if (driver.contains("sybase")) {
            return "sybase";
        }
        if (driver.contains("db2")) {
            return "db2";
        }
        if (driver.contains("hsqldb")) {
            return "hsqldb";
        }
        if (driver.contains("derby")) {
            return "derby";
        }
        if (driver.contains("h2")) {
            return "h2";
        }
        return driver;
    }

}
